<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
	<title>{:C('SERVER_HOME_NAME')}</title>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/login.css">
</head>
<body>

	


	<div class="register">
		<div class="register-box">
			<div class="login-img m20"><img src="__PUBLIC__/images/logo.png"></div>
			<div class="register-form"><input type="text" id="idInput" class="input-box" placeholder="输入账号"></div>
			<div class="register-form"><input type="password" id="pwInput" class="input-box" placeholder="登录面"></div>
			<div class="register-form"><input type="password" id="qdIput" class="input-box" placeholder="确认密码"></div>
			<div class="register-form"><input type="text" id="email" class="input-box" placeholder="电子邮箱"></div>
			<div class="register-form"><input type="text" id="number" class="input-box" placeholder="电子邮箱"></div>
			<div class="register-form"><span class="item">性别：</span><div class="gender"><span class="sex"><input type="radio" value="1" name="sex">男</span><span class="sex"><input type="radio" value="2" name="sex">女</span></div></div>
			<div class="register-form"><input type="checkbox" checked="true"><a href="javascript:void" class="protocol"
>我已阅读并同意遵守会员注册协议说明。</a></div>

	
			<div class="register-form"><div class="create"><a href="javascript:;" class="register-btn">创建账号</a></div></div>
			<div class="register-form form-center"><a href="login.html" class="font-color">已有账号？</a></div>
		</div>
	</div>
	
	
<include file="Public/ok" />
	
	<script src="__PUBLIC__/js/jquery-1.7.min.js"></script>
	<script src="__PUBLIC__/js/page.js"></script>
	<script type="text/javascript">
		$(function () {



			$(".register-btn").click(function () {
				var username=$("#idInput").val(),
				password=$("#pwInput").val(),
				email=$("#email").val(),
				tel=$("#number").val(),
				sex=$(".gender input:radio[name='sex']:checked").val();
				var emailreg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
				if (username=="") {
					 modelConfirm("账号不能为空",function(){
		                //TODO:提交
		            });
		            return false;
				}else if (password=="") {
					 modelConfirm("密码不能为空",function(){
		                //TODO:提交
		            });
		            return false;
				}else if ($("#qdIput").val()==""||$("#pwInput").val()!=$("#qdIput").val()) {
					 modelConfirm("确定密码为空，或者登录密码和确定密码不一致。",function(){
		                //TODO:提交
		            });
		            return false;
		            
		        }else if(email=="" || !(emailreg.test(email)) ){

		        	 modelConfirm("请输入正确的邮箱");
		        	 return false;
		        }else if (tel=="" || !(/^1[34578]\d{9}$/.test(tel)) ) {
					 modelConfirm("请输入正确的手机号",function(){
		                //TODO:提交
		            });
		            return false;
				}else if (sex==null) {
					 modelConfirm("请选择性别",function(){
		                //TODO:提交
		            });
		            return false;
				}else if ($(".state input").is(":checked")==false) {
					 modelConfirm("您未阅读并同意会员协议",function(){
		                //TODO:提交
		            });
		            return false;
				}
				else{
					 $.post('__URL__/register', {username:username,email:email,password:password,tel:tel,sex:sex}, function(data) {
					 		
					 	if(data==1){
					 		modelConfirm("注册成功",function(){
		               			window.location.href="{:U('Home/User/index')}";
		           			 });	
					 	}else if(data==2){
					 		modelConfirm("用户名或手机号已存在");
					 	}else{
					 		modelConfirm("注册失败");
					 	}	
					 });
				}
			})

		})
		

	</script>
</body>
</html>